package com.heima.wemedia.controller.v1;


import com.heima.common.dtos.PageResponseResult;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * 自媒体图文素材信息表 前端控制器
 * </p>
 *
 * @author QLJ
 * @since 2022-09-02
 */
@RestController
@RequestMapping("/api/v1/material/")
public class WmMaterialController {
    @Autowired
    private WmMaterialService wmMaterialService;


    /**
     * 自媒体上传文件
     */
    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(MultipartFile multipartFile){
        return wmMaterialService.uploadPicture(multipartFile);
    }


    /**
     * 查询素材集合
     */
    @PostMapping("/list")
    public PageResponseResult wmMaterialList(@RequestBody WmMaterialDto wmMaterialDto){
        return wmMaterialService.wmMaterialList(wmMaterialDto);
    }

    /**
     * 素材收藏
     */
    @GetMapping("/collect/{id}")
    public ResponseResult collect(@PathVariable Integer id){
        return wmMaterialService.collect(id);
    }


    /**
     * 素材取消收藏
     */
    @GetMapping("/cancel_collect/{id}")
    public ResponseResult cancelCollect(@PathVariable Integer id){
        return wmMaterialService.cancelCollect(id);
    }


    /**
     *删除素材
     */
    @GetMapping("/del_picture/{id}")
    public ResponseResult delPicture(@PathVariable Integer id){
        return wmMaterialService.delPicture(id);
    }


}

